<%--
  Created by IntelliJ IDEA.
  User: SCD
  Date: 2021/12/26
  Time: 13:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

    <%--ajax异步交互--%>
    <script src="${pageContext.request.contextPath}/js/jquery-3.5.1.js"/></script>
    <button id="btn1">ajax异步提交</button>
    <script>
        $("#btn1").click(function(){
            let url='${pageContext.request.contextPath}/user/ajaxRequest';
            let data='[{"id":1,"username":"张飞"},{"id":2,"username":"关羽"}]';
            $.ajax({
                type:'POST',
                url:url,
                data:data,
                contentType:'application/json;charset=utf-8',
                success:function (resp){
                    alert(JSON.Stringify(resp));
                }
            })
        })
    </script>
</body>
</html>
